﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using University.Workshop.Business;
using University.Workshop.Model;
using System.Resources;

namespace University.Workshop.WinApp
{
    public partial class NewRoomForm :TemplateForm
    {
        private ResourceManager resours;
        public NewRoomForm()
        {
            InitializeComponent();
            RoomStuffManager.GetAllRooms(roomDataGridView);
            resours = new ResourceManager(typeof(NewRoomForm));
        }

        private void buttonInsert_Click(object sender, EventArgs e)
        {
            String name = textBoxRoomName.Text.Trim();
            String type = (String)TypecomboBox.Text.Trim();
            // String type = ComboBoxTypes.SelectedItem.ToString();
            int idType = RoomStuffManager.GetByName(type);
            Room room = new Room(name, idType, 50);
            if (!RoomStuffManager.CreateNewRoom(room)) {
                string caption = this.resours.GetString("messageBox.Caption");
                MessageBoxButtons buttons = MessageBoxButtons.OK;
                MessageBox.Show(this, "rows select is invalid", caption, buttons, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign);
            }
            roomDataGridView.Rows.Clear();
            RoomStuffManager.GetAllRooms(roomDataGridView);
        }
    }
}
